<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace Mdanter\Ecc\Curves;

class CurveFactory
{
    public static function getCurveByName($NamedCurveFp, $name)
    {
        $adapter = \Mdanter\Ecc\Math\MathAdapterFactory::getAdapter();
        if($name == \Rtgm\ecc\Sm2Curve::NAME_PSM2) {
            return self::getSm2Factory($adapter)->curveSm2();
        }
        $nistFactory = self::getNistFactory($adapter);
        $secpFactory = self::getSecpFactory($adapter);
        switch ($name) {
            case NistCurve::NAME_P192:
                return $nistFactory->curve192();
                break;
            case NistCurve::NAME_P224:
                return $nistFactory->curve224();
                break;
            case NistCurve::NAME_P256:
                return $nistFactory->curve256();
                break;
            case NistCurve::NAME_P384:
                return $nistFactory->curve384();
                break;
            case NistCurve::NAME_P521:
                return $nistFactory->curve521();
                break;
            case SecgCurve::NAME_SECP_112R1:
                return $secpFactory->curve112r1();
                break;
            case SecgCurve::NAME_SECP_192K1:
                return $secpFactory->curve192k1();
                break;
            case SecgCurve::NAME_SECP_256K1:
                return $secpFactory->curve256k1();
                break;
            case SecgCurve::NAME_SECP_256R1:
                return $secpFactory->curve256r1();
                break;
            case SecgCurve::NAME_SECP_384R1:
                return $secpFactory->curve384r1();
                break;
            default:
                $error = new \Mdanter\Ecc\Exception\UnsupportedCurveException("Unknown curve.");
                $error->setCurveName($name);
                throw $error;
        }
    }
    public static function getGeneratorByName($GeneratorPoint, $name)
    {
        $adapter = \Mdanter\Ecc\Math\MathAdapterFactory::getAdapter();
        if($name == \Rtgm\ecc\Sm2Curve::NAME_PSM2) {
            return self::getSm2Factory($adapter)->generatorSm2();
        }
        $nistFactory = self::getNistFactory($adapter);
        $secpFactory = self::getSecpFactory($adapter);
        switch ($name) {
            case NistCurve::NAME_P192:
                return $nistFactory->generator192();
                break;
            case NistCurve::NAME_P224:
                return $nistFactory->generator224();
                break;
            case NistCurve::NAME_P256:
                return $nistFactory->generator256();
                break;
            case NistCurve::NAME_P384:
                return $nistFactory->generator384();
                break;
            case NistCurve::NAME_P521:
                return $nistFactory->generator521();
                break;
            case SecgCurve::NAME_SECP_112R1:
                return $secpFactory->generator112r1();
                break;
            case SecgCurve::NAME_SECP_192K1:
                return $secpFactory->generator192k1();
                break;
            case SecgCurve::NAME_SECP_256K1:
                return $secpFactory->generator256k1();
                break;
            case SecgCurve::NAME_SECP_256R1:
                return $secpFactory->generator256r1();
                break;
            case SecgCurve::NAME_SECP_384R1:
                return $secpFactory->generator384r1();
                break;
            default:
                $error = new \Mdanter\Ecc\Exception\UnsupportedCurveException("Unknown generator.");
                $error->setCurveName($name);
                throw $error;
        }
    }
    private static function getNistFactory($NistCurve, $math)
    {
        return new NistCurve($math);
    }
    private static function getSecpFactory($SecgCurve, $math)
    {
        return new SecgCurve($math);
    }
    private static function getSm2Factory($Sm2Curve, $math)
    {
        return new \Rtgm\ecc\Sm2Curve($math);
    }
}

?>